<?php
namespace AdminPanel\DashboardBundle\Utils;

class adminCustomClass
{
  public static function defineControllerName($controllerObject)
  {
    $matches = array();
    $pattern = "/Controller\\\\([a-zA-Z]*)Controller/";
    preg_match($pattern, $controllerObject->getRequest()->attributes->get("_controller"), $matches);
    if($matches[1]){
      
      // Set current bundle name to session
      $session = $controllerObject->getRequest()->getSession();
      $session->set('currentBundleName', $matches[1]);
      
      return $matches[1];
    }else{
      
      // Set current bundle name to session
      $session = $controllerObject->getRequest()->getSession();
      $session->set('currentBundleName', null);
      
      return null;
    }
    
  }
  
  public function convertIntoOraDate($date)
  {
    echo $date;die;
    $convertedDate = '';

    $year = substr($date, 0, 4);
    $month = substr($date, 5, 2);
    $day = substr($date, 8, 2);

    switch ($month) {
      case '01': {
          $month = 'JAN';
          break;
        }
      case '02': {
          $month = 'FEB';
          break;
        }
      case '03': {
          $month = 'MAR';
          break;
        }
      case '04': {
          $month = 'APR';
          break;
        }
      case '05': {
          $month = 'MAY';
          break;
        }
      case '06': {
          $month = 'JUN';
          break;
        }
      case '07': {
          $month = 'JUL';
          break;
        }
      case '08': {
          $month = 'AUG';
          break;
        }
      case '09': {
          $month = 'SEP';
          break;
        }
      case '10': {
          $month = 'OCT';
          break;
        }
      case '11': {
          $month = 'NOV';
          break;
        }
      case '12': {
          $month = 'DEC';
          break;
        }
      default : {
          return;
        }
    };


    $convertedDate = $day . '-' . $month . '-' . $year;
    return $convertedDate;
  }
  
  public static function clear($dirtyText)
  {
    $cleanText = $dirtyText;
    
    return $cleanText;
  }
  
}
?>
